/*
 * @Author: xiaosihan 
 * @Date: 2022-09-29 15:33:06 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-06-08 06:22:17
 */


//mesh
import { Mesh } from "three";
import threeLoader from "three-base/threeLoader";
import GLTF_GLB from "./GLTF.glb?url";
import build2GLTF from "./build2.gltf?url";
import build3GLTF from "./build3.gltf?url";
import build4GLTF from "./build4.gltf?url";
import MeshBase from "three-base/MeshBase";
import metalMaterial from "@views/materials/metalMaterial";
import utils from "@utils";
import threeUtils from "three-base/threeUtils";


// 加载 gltf格式的模型 例子
export default class GLTF extends Mesh {
    constructor() {
        super();
    }


    //大楼
    mesh = (() => {
        const mesh = new MeshBase(build4GLTF);

        mesh.addEventListener("loaded", () => {
            threeUtils.scaleTo(mesh, 10);
            mesh.traverseMesh(mesh => {
                mesh.material = metalMaterial;
                mesh.geometry.computeVertexNormals();

                //three事件
                mesh.userData = {
                    cursor: "pointer",
                    enableEvent: true,
                };
                mesh.addEventListener("dbclick", e => {
                    utils.editorMaterial(metalMaterial);
                });
            })
            this.add(mesh);
        });

        return mesh;
    })();


}